var ajax = function(method, url, callback) {

    var xhr = new XMLHttpRequest();
    xhr.open(method, url, true);
    xhr.send();

    xhr.onreadystatechange = function() {
        if (xhr.readyState == 4 && xhr.status == 200) {
            callback(JSON.parse(xhr.responseText));
        }
    }

};